using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using WalkingTec.Mvvm.Core;
using WalkingTec.Mvvm.Core.Extensions;
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations;
using HengTong.Model.Db.System;


namespace HengTong.ViewModel._Admin.SysBillRouteVms
{
    public partial class SysBillRouteListVm : BasePagedListVM<SysBillRouteView, SysBillRouteSearcher>
    {

        protected override IEnumerable<IGridColumn<SysBillRouteView>> InitGridHeader()
        {
            return new List<GridColumn<SysBillRouteView>>{
                this.MakeGridHeader(x => x.Name),
                this.MakeGridHeader(x => x.CodeType),
                this.MakeGridHeader(x => x.PcRoute),
                this.MakeGridHeader(x => x.MobileRoute),
                this.MakeGridHeaderAction(width: 200)
            };
        }

        public override IOrderedQueryable<SysBillRouteView> GetSearchQuery()
        {
            var query = DC.Set<SysBillRoute>()
                .CheckContain(Searcher.Name, x=>x.Name)
                .CheckContain(Searcher.CodeType, x=>x.CodeType)
                .CheckContain(Searcher.Route, x=>x.PcRoute)
                .Select(x => new SysBillRouteView
                {
				    ID = x.ID,
                    Name = x.Name,
                    CodeType = x.CodeType,
                    PcRoute = x.PcRoute,
                    MobileRoute = x.MobileRoute
                })
                .OrderBy(x => x.ID);
            return query;
        }

    }

    public class SysBillRouteView : SysBillRoute{

    }
}
